package it.cpyx.appengine.server.data;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Text;
import com.google.appengine.api.users.User;

@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class TextData {

	@PrimaryKey
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
	private Long id;
	
	@Persistent
	private String urlExtension;
	
	@Persistent
	private Text content;
	
	@Persistent
	private int hit;
	
	@Persistent
	private String pass;
	
	@Persistent
	private String title;
	
	@Persistent
	private User owner;
	
	@Persistent
	private Date date;
	
	@Persistent
	private Date lastEntry;
	
	@Persistent
	private Set<Long> labelDataList;
	
	@Persistent
	private Set<Long> usersDataList;
	
	@Persistent
	private Set<Long> commentTextDataList;

	/**
	 * @param urlExtension
	 * @param content
	 * @param pass
	 * @param title
	 * @param owner
	 */
	public TextData(String urlExtension, Text content, String pass,
			String title, User owner) {
		this.urlExtension = urlExtension;
		this.content = content;
		this.pass = pass;
		this.title = title;
		this.owner = owner;
		this.date=new Date();
		this.hit=0;
		this.labelDataList=new HashSet<Long>();
		this.usersDataList=new HashSet<Long>();
		this.commentTextDataList=new HashSet<Long>();
		this.lastEntry=new Date();
	}

	public String getUrlExtension() {
		return urlExtension;
	}

	public void setUrlExtension(String urlExtension) {
		this.urlExtension = urlExtension;
	}

	public Text getContent() {
		return content;
	}

	public void setContent(Text content) {
		this.content = content;
	}

	public int getHit() {
		return hit;
	}

	public void setHit(int hit) {
		this.hit = hit;
	}

	public String getPass() {
		return pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public User getOwner() {
		return owner;
	}

	public void setOwner(User owner) {
		this.owner = owner;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Date getLastEntry() {
		return lastEntry;
	}

	public void setLastEntry(Date lastEntry) {
		this.lastEntry = lastEntry;
	}

	public Set<Long> getLabelDataList() {
		return labelDataList;
	}

	public void setLabelDataList(Set<Long> labelDataList) {
		this.labelDataList = labelDataList;
	}
	
	public void addLabelDataList(Long labelId){
		this.labelDataList.add(labelId);
	}
	
	public void removeLabelDataList(Long labelId){
		this.labelDataList.remove(labelId);
	}
	
	public Set<Long> getUsersDataList() {
		return usersDataList;
	}

	public void setUsersDataList(Set<Long> usersDataList) {
		this.usersDataList = usersDataList;
	}
	
	public void addUsersDataList(Long textId){
		this.usersDataList.add(textId);
	}
	
	public void removeUsersDataList(Long textId){
		this.usersDataList.remove(textId);
	}

	public Set<Long> getCommentTextDataList() {
		return commentTextDataList;
	}

	public void setCommentTextDataList(Set<Long> textDataList) {
		this.commentTextDataList = textDataList;
	}
	
	public void addCommentTextDataList(Long textId){
		this.commentTextDataList.add(textId);
	}
	
	public void removeCommentTextDataList(Long textId){
		this.commentTextDataList.remove(textId);
	}

	public Long getId() {
		return id;
	}
	
	
	
}
